package com.zenaprod.twodcore.ui;

import com.zenaprod.framework.log.ZLog;
import com.zenaprod.twodcore.ui.menu.MenuView;

import java.awt.*;
import java.util.ArrayList;
import java.util.List;

public class Ui {
    protected List<MenuView> menuViews;
    protected boolean isVisible = true;

    public Ui() {
        this.menuViews = new ArrayList<MenuView>();
    }


    public void addMenuFrame(MenuView menuView) {
        menuViews.add(menuView);
    }

    public void close(MenuView menuView) {
        for(int i = 0 ; i < menuViews.size() ; i++) {
            if(menuViews.get(i).getName().equals(menuView.getName())) {
                menuViews.remove(i);
                break;
            }
        }
        ZLog.e("Menu View " + menuView.getName() + " is unknown");
    }

    public void draw(Graphics2D g2D) {
        if(!isVisible) {
            return;
        }
        for(MenuView menuView : menuViews) {
            menuView.draw(g2D);
        }
    }


    public void setVisible(boolean visible) {
        this.isVisible = visible;
    }

    public boolean isVisible() {
        return this.isVisible;
    }


    public void isInFrame(int clickX, int clickY) {

    }
}
